Method and apparatus for h.264 to mpeg-2 video transcoding

ABSTRACT

A method for transcoding from an H.264 format to an MPEG-2 format is disclosed. The method generally comprises the steps of (A) decoding an input video stream in the H.264 format to generate a picture having a plurality of macroblock pairs that used an H.264 macroblock adaptive field/frame coding; (B) determining a mode indicator for each of the macroblock pairs; and (C) coding the macroblock pairs into an output video stream in the MPEG-2 format using one of (i) an MPEG-2 field mode coding and (ii) an MPEG-2 frame mode coding as determined from the mode indicators.

This is a divisional of U.S. Ser. No. 12/910,169, filed Oct. 22, 2010,which is a divisional of U.S. Ser. No. 11/198,455, filed Aug. 5, 2005,which are both incorporated by reference.

The present invention is related to copending U.S. patent applicationSer. No. 11/198,456, filed Aug. 5, 2005, Ser. No. 11/198,694, filed Aug.5, 2005, Ser. No. 11/198,448, filed Aug. 5, 2005, Ser. No. 11/198,457,filed Aug. 5, 2005 and Ser. No. 11/198,435, filed Aug. 5, 2005, allhereby incorporated by reference in their entirety.

FIELD OF THE INVENTION

The present invention relates to video transcoding generally and, moreparticularly, to a method and an apparatus for H.264 to MPEG-2 videotranscoding.

BACKGROUND OF THE INVENTION

A significant amount of video content is currently available in theMPEG-2 format. Furthermore, a large number of both cable set top boxesand satellite set top boxes that only support the MPEG-2 format arecurrently deployed. Therefore, compatibility with the MPEG-2 standardwill remain important for years to come.

An H.264/MPEG4-AVC digital video standard (H.264 for short) is anemerging new format for consumer video, particularly in both newbroadcast and High-Definition (HD) Digital Versatile Disk (DVD)applications. A Society of Motion Picture and Television Engineers(SMPTE) VC-1 digital video standard is an emerging new format forconsumer video, particularly in both new video over Internet Protocol(IP) and high definition DVD applications. As H.264 based and VC-1 basedcontent and products become available, transcoding in both directions(i) between the H.264 standard and the MPEG-2 standard, (ii) between theVC-1 standard and the MPEG-2 standard and (iii) between the H.264standard and the VC-1 standard will become widely used capabilities.Anticipated consumer applications include reception of MPEG-2 broadcastsby a personal video recorder (PVR) and transcoding to either H.264 orVC-1 for saving on disk storage space. In another example, reception ofH.264 or VC-1 satellite, H.264 or VC-1 cable broadcasts and VC-1 networkbroadcasts by a DVD recorder, transcoding the H.264/VC-1 material intoMPEG-2 and then recording to a compatible DVD-R, DVD+R, DVD-RW and/orDVD+RW format magnetic disk or optical disk. The H.264 material is alsoexpected to be transcoded into the VC-1 format for storage and displayon a personal computer. Professional applications are also widelyanticipated. Such applications include H.264 to MPEG-2 transcoding andVC-1 to MPEG-2 transcoding for content received at a headend facility inthe H.264/VC-1 format that is transcoded into the MPEG-2 format or theVC-1 format for the “last mile” for compliance with currently deployedreceivers. In another example, MPEG-2 to H.264/VC-1 transcoding could beused to save bandwidth for expensive transmission media such assatellite links. In still another example, MPEG-2 to H.264/VC-1transcoding could be used for video server/video on demand (VOD)applications where the content could be stored in H.264/VC-1 for diskspace savings and then transcoded to MPEG-2, H.264 or VC-1 formatsupported by a requesting client. Furthermore, the consumer market is alarge market with strict complexity/cost constraints that will benefitsubstantially from an efficient and effective transcoding technology.

SUMMARY OF THE INVENTION

The present invention concerns a method for transcoding from an H.264format to an MPEG-2 format. The method generally comprises the steps of(A) decoding an input video stream in the H.264 format to generate apicture having a plurality of macroblock pairs that used an H.264macroblock adaptive field/frame coding; (B) determining a mode indicatorfor each of the macroblock pairs; and (C) coding the macroblock pairsinto an output video stream in the MPEG-2 format using one of (i) anMPEG-2 field mode coding and (ii) an MPEG-2 frame mode coding asdetermined from the mode indicators.

The objects, features and advantages of the present invention includeproviding a method and/or apparatus for video transcoding that mayprovide (i) low-complexity, high-quality H.264 to MPEG-2 transcoding,(ii) low-complexity, high-quality MPEG-2 to H.264 transcoding, (iii)low-complexity, high-quality VC-1 to MPEG-2 transcoding, (iv)low-complexity, high-quality MPEG-2 to VC-1 transcoding, (v)low-complexity, high-quality H.264 to VC-1 transcoding, (vi)low-complexity, high-quality VC-1 to H.264 transcoding and/or (vii) ahardware architecture that may allow for efficient transcoding within asingle chip (or die).

BRIEF DESCRIPTION OF THE DRAWINGS

These and other objects, features and advantages of the presentinvention will be apparent from the following detailed description andthe appended claims and drawings in which:

FIG. 1 is a functional block diagram of a first system in accordancewith a preferred embodiment of the present invention;

FIG. 2 is a functional block diagram of a second system;

FIG. 3 is a flow diagram of an example method for an MPEG-2 macroblockadaptive field/frame decode order;

FIG. 4 is a diagram of an example hierarchical group of pictures for anH.264 stream;

FIG. 5 is a block diagram of an example implementation of a thirdsystem;

FIG. 6 is a detailed block diagram of an example implementation for avideo digital signal processor module; and

FIG. 7 is a graph of an example time line for different videotranscoding operations.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Referring to FIG. 1, a functional block diagram of a first system 100 isshown in accordance with a preferred embodiment of the presentinvention. The first system (or circuit) 100 may be referred to as avideo transcoder. The video transcoder 100 generally comprises a decodermodule (or function) 102 and an encoder module (or function) 104. Asignal (e.g., IN) may be received by the decoder module 102. The decodermodule 102 may generate a signal (e.g., VID) and generate one or moresignals, generally represented by a signal (e.g., DATA). The encodermodule 104 may receive the signals VID and DATA. A signal (e.g., OUT)may be presented by the encoder module 102.

The signal IN may be a compressed digital video bitstream compliant witha starting video standard (or format). The starting video standard maybe one of an MPEG-2 standard, an H.264 standard and a VC-1 standard. Thesignal VID may be a non-compressed digital video signal in an interlacedformat or a progressive format. The signal OUT may be a compresseddigital video bitstream compliant with an ending video standard (orformat). The ending video standard may be one of the MPEG-2 standard,the H.264 standard and the VC-1 standard. In general, the startingformat of the compressed information in the signal IN is different fromthe ending format of the compressed information in the signal OUT.

The signal DATA generally comprises one or more types of informationand/or indicators extracted from the signal IN during a decodingoperation. The information/indicators in the signal DATA may be usefulin coding the signal VID during an encoding operation. The signal DATAmay convey one or more of the following (i) motion compensation modes,(ii) motion vectors, (iii) coefficient scan order, (iv) file/framecoding mode, (v) macroblock adaptive field/frame information (MBAFF),(vi) picture adaptive field/frame information and/or similar informationobtained while decoding the signal IN.

Implementation of the video transcoder 100 may comprise a single chip(or die) in (on) which both the decoder module 102 and the encodermodule 104 may be formed. In another embodiment, the video transcoder100 may comprise two chips (or die). A first chip of the videotranscoder 100 may comprise the decoder module 102. A second chip of thevideo transcoder 100 may comprise the encoder module 104.

Referring to FIG. 2, a functional block diagram of a second system 120is shown. The second system (or circuit) 120 may be referred to as asecond video transcoder. The second video transcoder 120 generallycomprises a decoder module (or function) 122, an encoder module (orfunction) 124 and a memory module (or function) 126. The decoder module122 may receive the signal IN and generate the signal DATA. Anintermediate signal (e.g., INTa) may be presented by the decoder module122 to the memory module 126. The encoder module 124 may receive thesignal DATA and present the signal OUT. A second intermediate signal(e.g., INTb) may be received by the encoder module 124 from the memorymodule 126.

The intermediate signals INTa and INTb may be used to transfer pixelinformation from the decoder module 122 to the encoder module 124. Thepixel information may be buffered in the memory module 126 untilutilized by the encoder module 124.

In some embodiments, the video transcoder 120 may be implemented as asingle chip (or die) 128. The chip 128 may comprise the decoder module122, the encoder module 124 and the memory module 126. The memory module126 and the intermediate signals INTa and INTb may provide a capabilityto transfer partially decoded pictures from the decoder module 122 tothe encoder module 124 before the decoder module 122 has completeddecoding of the entire picture. As such, the encoder module 124 mayoperate substantially in parallel with the decoder module 122 byoperating on the same picture substantially simultaneously. The memorymodule 126 may also be capable of temporarily buffering one or morefully decoded pictures. Therefore, the decoder module 122 may operate atleast one picture ahead of the encoder module 124 with the memory module126 storing all indicators for all macroblocks of the buffered pictures.

The first video transcoder 100 and/or the second video transcoder 120(generically referred to as a video transcoder) may be operational toconvert the signal IN from an original video standard (or format) to atranscoded video standard (or format). Transcoding may include, but isnot limited to, (i) the MPEG-2 format to the H.264 format conversion,(ii) the H.264 format to the MPEG-2 format conversion, (iii) the MPEG-2format to the VC-1 format conversion, (iv) the VC-1 format to the MPEG-2format conversion, (v) the H.264 format to the VC-1 format and (vi) theVC-1 format to the H.264 format.

Transcoding from MPEG-2 to H.264

Transcoding from the MPEG-2 standard to the H.264 standard generallyraises several problems. For example, the use of a raster scan order of16×16 macroblocks in the MPEG-2 does not directly convert into theraster scan of 32×16 macroblock pairs in H.264. Furthermore, the use ofa regular group of pictures (GOP) in MPEG-2 is not directly translatableinto a hierarchical GOP structure in H.264. The MPEG-2 standardconsistently uses either field coding or frame coding within anindependently decodable sequence of pictures (e.g., MPEG-2 GOP). TheMPEG-2 standard also allows for field/frame picture coding, adaptivelyselected at picture boundaries. The H.264 standard may switch on apicture basis between field coding, frame coding and MBAFF coding. TheMPEG-2 standard provides separate signaling of motion compensationfield/frame mode and coefficient field/frame scan order whereas theH.264 standard does not. Still furthermore, field/frame macroblockdecisions may be made independently for each macroblock in MPEG-2 whileH.264 uses a field/frame macroblock decision for a macroblock pair.

Several capabilities may be implemented in the video transcoders of thepresent invention to resolve one or more of the above problems. Considera vertical pair of macroblocks coded per the MPEG-2 standard. Generally,four indicators may exist in the two original MPEG-2 macroblocks of thepair that indicate a correct H.264 field/frame mode to use for atranscoded MB pair. In particular, the four indicators may comprise (i)a motion compensation mode (e.g., field or frame) for the top macroblockof the pair, (ii) a coefficient scan order (e.g., field or frame) forthe top macroblock, (iii) a motion compensation mode (e.g., field orframe) for the bottom macroblock of the pair and (iv) a coefficient scanorder for the bottom macroblock.

If either of the original two macroblocks use a field motioncompensation mode, the transcoded macroblock pair may use the fieldmotion compensation mode. Optionally, if either or both of the originaltwo macroblocks use both a field coefficient scan and have a significantresidual (e.g., generally contains non-zero coefficients), thetranscoded macroblock pair may use the field motion compensation mode.

For transcoding MPEG-2 pictures to H.264 MBAFF pictures, the macroblockscan order for the MPEG-2 decoding, which is typically raster order, maybe done in MBAFF scan order. Decoding in the MBAFF scan order may bepossible because (i) an MPEG-2 stream should have a startcode at a startof each macroblock row and (ii) spatial prediction may only depend oneach leftmost macroblock.

Referring to FIG. 3, a flow diagram of an example method 160 for anMPEG-2 MBAFF decode order is shown. The method (or process) 160generally comprises a step (or block) 161, a step (or block) 162, a step(or block) 163, a step (or block) 164, a step (or block) 165, a step (orblock) 166, a step (or block) 167, a step (or block) 168, a step (orblock) 169, a step (or block) 170, a step (or block) 171, a step (orblock) 172, a step (or block) 173, a step (or block) 174, a step (orblock) 175 and a step (or block) 176.

A portion (e.g., greater than one row of macroblocks) of the signal INmay be buffered in the step 161. The method 160 may detect a start of apicture in the step 162 (e.g., a startcode for an initial macroblockrow) and detect a start code for a first odd row of macroblocks (e.g.,row 1) in the step 163. A start code for a first even row of macroblocks(e.g., row 2) may be detected in the step 164.

A first macroblock in the current odd row may be decoded in the step165. The position of the just-decoded first odd row macroblock may bestored as a first position (e.g., a position A) in the step 166. A firstmacroblock in the current event row may be decoded in the step 167. Theposition of the just-decoded first even row macroblock may be stored asa first position (e.g., a position B) in the step 168. The firstmacroblock in the odd row and the first macroblock in the even row mayform a macroblock pair. The macroblock in the odd row may be referred toas a top macroblock of the pair. The macroblock in the even row may bereferred to as a bottom macroblock of the pair.

To decode a next macroblock pair, the method 160 may reposition thebuffered portion of the signal IN to a macroblock in the odd row (e.g.,a position A=A+1) adjoining the first macroblock at the originalposition A in the step 169. The second macroblock in the odd row may bedecoded in the step 170. The method 160 may reposition to a macroblockin the even row (e.g., a position B=B+1) adjoining the first macroblockat the original position B in the step 171. A second macroblock in theeven row may then be decoded in the step 172. If the decoded macroblockdoes not end the row (e.g., the NO branch of step 173), the bitstream(e.g., signal IN) may be repositioned to a next macroblock in the oddrow (step 169), the macroblock decoded (step 170), the bitstreamrepositioned to the next even row macroblock (step 171) and themacroblock decoded (step 172) until the end of a row is reached (e.g.,the YES branch of step 173).

Once an end (e.g., rightmost macroblocks) of the current two rows havebeen decoded, the method 160 may check for an end of the picture in step174. If the picture is not fully decoded (e.g., the NO branch of step174), a start code for a next odd row (e.g., row 3) may be detected inthe step 175. The start code for a next even row (e.g., row 4) may bedetected in the step 176. The method 160 may continue with decoding afirst macroblock in the new odd row in the step 165. The position A ofthe just-decoded macroblock may be stored in the step 166. A firstmacroblock in the new even row may be decoded in the step 167 and theposition B updated in the step 168. Decoding of the macroblock pairs,may continue until the end of the row (e.g., the YES branch of step173). Decoding of the macroblock pairs may continue with subsequent rowsuntil the end of the picture is reached (e.g., the YES branch of step174).

Another approach that may be implemented in transcoding from MPEG-2 toH.264 may be a reuse of one or both of (i) an MPEG-2 quantizationparameter (QP) and (ii) a number of bits used per macroblock decoding.The MPEG-2 QP and/or number of bits used per macroblock may provide theencoding process a macroblock complexity indication. The macroblockcomplexity indication may be utilized by the H.264 coding process foradjusting an encoder rate control.

Another indicator that may be passed from the decoder module to theencoder module may be the MPEG-2 motion vectors from each decodedpicture. The MPEG-2 motion vectors may be used by the encoder module toplace a search center of an H.264 motion estimation. The H.264 motionestimation may refine the MPEG-2 vectors to obtain a refined motionvector for H.264 encoding for modes that may not be supported by theMPEG-2 standard. The unsupported elements may include, but are notlimited to, different block sizes, smaller sub-pel accuracy (e.g., from½ pel to ¼ pel), use of multiple reference pictures, and search with aweighted prediction.

The decoder module may present MPEG-2 intra-frame concealment motionvectors to the encoder module as a starting point for a motion vectorrefinement. The MPEG-2 intra-frame concealment motion vectors may bepassed along if an i-frame from MPEG-2 is changed to a predicted framein H.264 and the MPEG-2 I-frame contains the intra-frame concealmentmotion vectors.

MPEG-2 fcodes may also be transferred from the decoder module to theencoder module. The MPEG-2 fcodes generally help (i) determine a size ofthe motion vector refine achieved by the H.264 coding and (ii) determinea direct mode selection (e.g., spatial or temporal). If the fcodes arelarge (e.g., large motion), the H.264 coding operation may use a spatialdirect selection. Otherwise, the H.264 coding operation may use atemporal direct selection.

Transcoding H.264 to MPEG-2.

The video transcoder may be configured to transcode from the H.264standard to the MPEG-2 standard. Problems for H.264 to MPEG-2transcoding generally include use of multiple and flexibly assignedreference frames in H.264 compared with a single reference frame inMPEG-2 that may be very constrained. Furthermore, the H.264 standardprovides more partitions (e.g., 16×16, 16×8, 8×16, 8×8, 8×4, 4×8 and4×4) than available in MPEG-2 (e.g., 16×16, and 16×8 field mode).

Several capabilities may be implemented in the video transcoder toresolve one or more of the above problems. For example, only oneindicator generally exists in H.264 for both macroblocks in a MB pair(in an MBAFF frame) about how to code the two vertically adjacentmacroblocks. To transcode, whatever the macroblock-pair mode is in theH.264 stream (e.g., field or frame) may become the motion compensationmode of the transcoded MPEG-2 stream for the two macroblockscorresponding to the MBAFF pair. Furthermore, the scan order of theMPEG-2 macroblocks may be seeded to the same in H.264. The scan order ofthe MPEG-2 macroblocks may optionally be refined using further analysisto potentially switch modes if justified. The analysis may includecomparing a residual vertical field and frame activities, using resultsfrom a frame and field H.264 intra estimator, checking frame and fieldmacroblock or block variances, analyzing frame and field macroblock orblock high frequency indicators, examining frame and field macroblock orblock motion indicators and the like.

A similar situation to the above generally exists for field-codedpictures in H.264. If the pictures are to be transcoded to MPEG-2 framepictures, then the macroblock modes may be set to field, with a defaultfield scan and an optional refinement of the scan. In anotherembodiment, the H.264 field pictures may be transcoded to MPEG-2 fieldpictures. Furthermore, an MPEG-2 discrete cosine transform (DCT) scantype decision for a field frame decision may be used for encoding, forintra macroblocks when motion vectors are not available.

If multi-reference frames are used in H.264, then the H.264 motionvectors may be resealed by the decoder module so that the new seedmotion vectors for the MPEG-2 stream may be given by equation 1 asfollows:

SeedMV=Original_MV*(new_currentpic_(—) TR−new_referencepic_(—)TR)/(old_currentpic_(—) TR−old_referencepic_(—) TR),  Eq. (1)

where TR generally indicates a temporal position of a picture

If a picture adaptive field/frame (AFF) mode is used in an H.264 stream,the resulting MPEG-2 stream may be transcoded to a frame sequence,rather than a field sequence. The MB field/frame motion compensationmode and the field/frame scan order modes may be determined as before.Selection of the frame sequence or field sequence in the MPEG-2 streammay be performed on a frame-by-frame basis.

Referring to FIG. 4, a diagram of an example hierarchical (or pyramidal)group of pictures for an H.264 stream is shown. Memory managementcontrol operation commands may be used to control what frames remains inthe reference buffer. A picture order count (generally intended as adisplay order in practice) may be used for ordering the B referencelists. A frame number is generally used for ordering the P referencelists (the frame number may be intended to distinguish referenceframes). H.264 only has completely arbitrary scaling of both referenceframes on a macroblock basis (e.g., lighting effects).

If a hierarchical GOP is used for the H.264 stream, the following rulesmay be followed for a high quality transcoding (i) generate an MPEG-2I-frame wherever an H.264 I-frame is found and (ii) place the MPEG-2reference frames such that as many of the original frames were referenceframes as possible. A preference generally exists for using thereference frames that were highest in the original hierarchy since thehighest reference frames generally have been coded at a highest quality.The most desirable pictures to use as reference frames are generallyreference I-frames. The next most desirable reference pictures may bereference frames that contain I-frames as predictors and are nearest tothe I-frames. Third most desirable reference pictures may be referenceframes that contain as a reference the previously mentioned pictures andare nearest to the previously mentioned pictures, and so on. Therefore,all frames may be ordered by desirability to become reference frames.The MPEG-2 GOP may then be adjusted to maximize a score for using aleast number of “undesirable” frames as reference frames in thetranscoded video.

If the H.264 macroblock partition is 16×16, the transcode operation maymap to MPEG-2 16×16 or 16×8 (for field macroblocks) partitions. If theH.264 partition is 16×8, the transcode operation may test the 16×8 fieldpartition regardless of a field/frame decision. Smaller H.264 partitionsmay be combined to form a smallest common MPEG-2 partition.

Where small H.264 partitions have been combined to match a size of anMPEG-2 partition, the multiple motion vectors of the multiple H.264partitions may be combined to generate a motion vector for the largerMPEG-2 partition. Combining H.264 motion vectors may involve an average,a median or a mode (e.g., occupying the most area) of the H.264 motionvectors. The median combining may be either (i) a vector median or (ii)a component median (e.g., x and y direction components may be separatefrom each other). Furthermore, the average/median/mode may be weightedby a size of the partitions. Once the encoder module has received themotion vectors from the decoder module, the H.264 motion vectors may berefined from the MPEG-2 motion vectors.

For a 3-point vector median calculation, an output vector may be avector that is opposite (not an end point of) a longest vector joiningany two input vectors. For example, starting with three input vectors:A, B and C, determination of the (output) vector median may be given asfollows:

1) Find

M=max(|A−B|, |A−C|, |B−C|), where |x-y| may indicate a Euclideandistance. (Other distance metrics may be used, for example, L1-norm vs.L2-norm may be used.)

2) If M=|A−B|

Output=C

Else IF M=A−C

Output=B

Else // M=|B−C|

Output=A

Where M matches a single difference metric (e.g., M=|A−B|), the medianmay be set to the remaining input vector (e.g., Output=C). Where Mmatches two or more difference metrics (e.g., M=|A−B|=|A−C|), the medianmay be set based on a priority (e.g., C is higher priority than B and Bis higher priority than A). The above median technique may be used inother transcoding format combinations.

Transcoding MPEG-2 to VC-1

Several problems generally exist in transcoding from the MPEG-2 standardto the VC-1 standard. An example problem may involve consistently usingeither field coding or frame coding within an independently decodablesequence of pictures (e.g., MPEG-2 GOP) and switching on a picture basisbetween field coding, progressive frame coding and interlaced framecoding.

To overcome the above problem, the video transcoder may reuse one orboth of (i) the MPEG-2 quantization parameter (QP) and (ii) bits usedper macroblock for a macroblock complexity indicator in a VC-1 encoderrate control. In another example, the MPEG-2 motion vectors may be usedto place a VC-1 search center of a motion estimation to refine theMPEG-2 vectors to obtain a refined motion vector for VC-1 encoding formodes generally not supported by MPEG-2. The unsupported MPEG-2 featuresgenerally include, but are not limited to (i) different block sizes,(ii) sub-pel accuracy (e.g., from ½ pel to ¼ pel) and (iii) searcheswith intensity compensated reference pictures.

The MPEG-2 intra-frame concealment motion vectors may be used as astarting point for a VC-1 motion vector refinement. The intra-frameconcealment motion vectors may be used if an I-frame from MPEG-2 ischanged to a predicted frame in VC-1 and that frame containedconcealment motion vectors. Furthermore, MPEG-2 fcodes may be used tohelp determine a size of the VC-1 motion vector refine. Still further,magnitudes of the DC and low-order AC coded coefficients from MPEG-2 maybe used to select the transform block size for VC-1.

Transcoding from MPEG-2 to VC-1 may involve mapping the MPEG-2partitions into the VC-1 partitions. The mapping into VC-1 may besimilar to the mapping of the MPEG-2 partitions into the H.264partitions. In particular, the MPEG-2 16×16 and 16×8 field partitionsmay be mapped into VC-1 16×16 and 16×8 partitions, respectively.

Transcoding VC-1 to MPEG-2

Transcoding from the VC-1 standard to the MPEG-2 standard createsmultiple issues involving capabilities in VC-1 not found in MPEG-2. Forexample, VC-1 has multiple ways to partition a macroblock for motioncompensation (e.g., 16×16, 16×8 field, 8×8 and 8×8 field). In contrast,MPEG-2 generally has only two choices (e.g., 16×16 or 16×8 field).Furthermore, VC-1 generally uses an intensity compensation while MPEG-2does not offer such a coding option. The VC-1 format generally usesrange reduction whereas MPEG-2 does not. Still further, VC-1 may use abitplane coding to efficiently encode Boolean macroblock-level flags foran entire picture within the picture header. MPEG-2 may only allowcoding of such flags within the macroblock layer. Furthermore, the VC-1format may use multiple transform block sizes (e.g., 8×8, 8×4, 4×8,4×4). In contrast, MPEG-2 may only perform an 8×8 transform.

The video transcoder may be configured to overcome one or more of theabove problems. For VC-1 interlaced frame pictures, the motioncompensation mode (e.g., field or frame) of each VC-1 macroblock may bereused for MPEG-2. Reuse of data from VC-1 directly to MPEG-2 may alsoapply to the DCT transform mode. A similar situation to the abovegenerally exists for field-coded pictures in VC-1. If the VC-1field-coded pictures are to be transcoded to MPEG-2 frame-pictures, thenthe MPEG-2 macroblock modes may be set to the field mode. In anotherembodiment, the VC-1 field pictures may be transcoded to MPEG-2 fieldpictures.

If a motion vector switch (MVSW) option is used in VC-1, a direction ofa first motion vector may be used as-is. However, a direction of asecond motion vector (e.g., every other motion vector) may be reversedand scaled. The reversed motion vector may be scaled into an oppositereference frame from the first motion vector based on relative temporaldistances.

If picture AFF is used in a VC-1 stream, the resulting MPEG-2 stream maybe transcoded to a frame sequence, rather than a field sequence. Thepicture AFF transcoding operation may use the methods discussed abovefor determining the MB field/frame motion compensation and field/framescan order modes. Selection of the frame sequence or the field sequencein the MPEG-2 stream may be determined on a frame-by-frame basis.

If the VC-1 macroblock partition is 16×16 or 16×8 for field macroblocks,the VC-1 macroblock partitions may be mapped to the same mode in MPEG-2.If the VC-1 partition is an 8×8 frame partition, then four 8×8partitions may be combined into a 16×16 partition before transcoding. Ifthe VC-1 partition is 8×8 field, then two 8×8 partitions may be combinedinto a 16×8 field partition.

Combining the small VC-1 partitions into a larger MPEG-2 partition mayresult in changes to the VC-1 motion vectors. To convert the VC-1 motionvectors to MPEG-2 motion vectors of the combined partition, the videotranscoder may calculate an average motion vector, a median motionvector or a mode motion vector (e.g., occupying the most area) togenerate a motion vector for the larger MPEG-2 partition. The medianmotion vectors may be one of (i) a vector median or (ii) a component(e.g., x and y direction components may be separate from each other)median. Furthermore, the VC-1 motion vectors may be used as startingseed directions for refining the MPEG-2 motion vectors.

Transcoding VC-1 to H.264

The video transcoder may be configured to transcode from the H.264standard to the VC-1 standard. Problems for H.264 to VC-1 transcodinggenerally include converting a raster scan order of individualmacroblocks to a raster scan order of macroblock pairs and converting aregular GOP structure to a hierarchical GOP structure. In addition,differences in the standards may exist for field/frame macroblockdecisions, range reduction/range mapping to encode sample values at areduced dynamic range and different transform block sizes.

Multiple indicators generally exist in two spatially adjoining originalVC-1 macroblocks for which H.264 field/frame mode to use for amacroblock pair. The indicators include a motion compensation mode(e.g., field/frame) for a top-macroblock of the two VC-1 macroblocks, acoefficient scan order (e.g., field/frame) for the top-macroblock, amotion compensation mode (e.g., field/frame) for a bottom-macroblock ofthe two VC-1 macroblocks and a coefficient scan order of the bottommacroblock.

If either or both of the original two VC-1 macroblocks uses field motioncompensation, the transcoded H.264 macroblock pair may use the fieldmode. Optionally, if either or both of the original two VC-1 macroblocksuses a field coefficient scan and has a significant residual (e.g.,contains non-zero coefficients), the transcoded H.264 macroblock-pairmay use the field mode.

If the macroblock uses the VC-1 direct mode prediction, the transcodedmacroblock may use an H.264 temporal direct mode for the H.264 encoding.Specifically, the temporal direct mode may be used for H.264 slices whendoing VC-1 to H.264 transcoding so that the VC-1 temporal direct modemacroblock decision may be used to help decide H.264 direct mode or not,as opposed to using a spatial direct mode for the H.264. Use of theH.264 spatial direct mode may yield predictions that differ more fromthe VC-1 direct mode predictions.

An H.264 intra-prediction direction may be determined by a VC-1intra-prediction direction. In particular, the VC-1 8×8 intra-predictiondirection selection (e.g., horizontal, vertical, DC) may be used whenselecting the H.264 directional predictions.

An H.264 High Profile encoding may use 8×8 intra-predictions. An H.264Main Profile encoding may use 4×4 intra-predictions that may all be thesame within an 8×8.

A VC-1 quantization parameter (QP) and bits used per macroblock formacroblock complexity indicator may be reused in an H.264 encoder ratecontrol. Furthermore, one or more VC-1 motion vectors may be used toplace one or more respective search centers of a motion estimation torefine the VC-1 vectors. The refinement generally results in refinedmotion vectors for the H.264 encoding for modes that may not besupported, or only optionally supported, by VC-1. The modes may include,but not limited to, different block sizes, subpel accuracy (e.g., from ½pel to ¼ pel), use of multiple reference pictures, to search withweighted prediction and the like.

Transcoding H.264 to VC-1

The video transcoder may be configured to transcode from the VC-1standard to the H.264 standard. A single indicator is generally used inthe H.264 standard for both macroblocks within a macroblock pair in anMBAFF frame. The single indicator generally identifies how to code twovertically adjacent macroblocks. As such, whatever macroblock-pair mode(e.g., field or frame) is received in an H.264 stream may be used as themotion compensation mode of the transcoded VC-1 stream for the two VC-1macroblocks corresponding to the H.264 MBAFF pair. The coefficient scanorder (e.g., field or frame) of the VC-1 macroblocks may be seeded tothe same scan order of the H.264 MBAFF pair. Optionally, the scan orderfor VC-1 macroblocks may be refined using further analysis topotentially switch modes if justified (e.g., by comparing residualvertical field and frame activities, or by using results from a frameand field H.264 intra estimator).

A similar situation to the above exists for field-coded pictures in theH.264 format. In transcoding the H.264 field-coded pictures into VC-1frame-pictures, the macroblock modes may be set to field, with a defaultof field scan, and an optional refinement of the scan may be performed.Alternatively, the H.264 field pictures may be transcoded into VC-1field pictures.

VC-1 slices may end only at the right end of a macroblock row, whereasH.264 slices do not have a similar limitation (e.g., an H.264 slice mayend mid-row). As such, the present invention generally avoids look-aheadprocessing and the associated additional delay by finishing themacroblock row in which the H.264 slice ends to form the VC-1 slice.

Transcoding from the H.264 format to the VC-1 format may account fordifferences in the number of applicable reference frames. If multiplereference frames were used in generating the H.264 frame, the motionvectors associated with the H.264 frame may be rescaled to establish newseed motion vectors for the transcoded VC-1 frame in a single referenceframe. Rescaling of each H.264 motion vector may be performed accordingto equation 2 as follows:

Seed_MV=Original_MV*(new_currentpic_(—) TR−new_referencepic_(—)TR)/(old_currentpic_(—) TR−old_referencepic_(—) TR),  Eq. (2)

where TR generally indicates the temporal position of a picture.

If picture AFF is used in an H.264 stream, the resulting VC-1 stream maybe transcoded to a frame sequence, rather than a field sequence. Thetranscoding may use the method discussed above for determining themacroblock field/frame motion compensation and field/frame scan ordermodes.

If a hierarchical GOP is used for the H.264 stream (see FIG. 4) and if ahigh quality transcode is planned, the following rules may be followed:(i) place a VC-1 I-frame wherever an H.264 I-frame is used and (ii)place the VC-1 reference frames such that as many of the original frameswere reference frames as possible, with a preference toward using thereference frames that were highest in original hierarchy (since suchframes will typically have been coded at highest quality). The mostdesirable pictures to use as reference frames are generally referenceI-frames. The next most desirable pictures to use as reference framesmay be reference pictures that contain i-frames as predictors and arenearest to the predictor I-frames. Third most desirable pictures may bereference pictures that contain as references the previously mentionedpictures and are nearest to the previously mentioned pictures, and soon. As such, all frames may be ordered by desirability to becomereference frames. The VC-1 GOP may then be adjusted to maximize a scorefor using the least number of “undesirable” frames as reference framesin the transcoded video.

If the H.264 macroblock partition is 16×16, the transcoding may map theH.264 macroblocks into a VC-1 16×16 partition or a 16×8 partition (forfield macroblocks). If the H.264 partition is 16×8, a test may beconducted for transcoding to a VC-1 field 8×8 partition regardless ofanother field/frame decision. Smaller H.264 partitions may be combinedto match a smallest common VC-1 partition.

Where two or more H.264 partitions are combined to form a single VC-1partition, the H.264 motion vectors may also be combined to form theVC-1 motion vector. The combinations may calculate average, median ormode (occupying the most area) motion vectors from smaller H.264partitions to get the VC-1 larger partition motion vectors. The medianmay be a vector median or component (e.g., an x-component separate froma y-component) median. Furthermore, the average/median/mode calculationsmay be weighted by a size of the partitions. The combined motion vectorsmay be use as calculated or use as seed positions for determiningrefined motion vectors. Still further, magnitudes of the DC andlow-order AC coded coefficients from H.264 may be used to select thetransform mode for VC-1.

Referring to FIG. 5, a block diagram of an example implementation of athird system 180 is shown. The system (or circuit) 180 may be referredto as a video transcoder. The video transcoder 180 may implement thevideo transcoder 100 or the video transcoder 120. The video transcoder180 generally comprises a processor module (or circuit) 182, a processormodule (or circuit) 184 and a memory module (or circuit) 186. Theprocessor module 184 may be directly coupled to the processor module 182and the memory module 186. The signal IN may be received by theprocessor module 184. The signal OUT may be presented by the processormodule 184.

The processor module 182 may be implemented as a SPARC processor. TheSPARC processor 182 may be operational to perform portions of thedecoding operations and the encoding operations in software. The SPARCprocessor 182 may also be operational to control the processor module184. Other types of processors may be implemented to meet the criteriaof a particular application.

The processor module 184 may be implemented as a video digital signalprocessor (VDSP). The VDSP module 184 may be operational to performportions of the decoding operations and portions of the encodingoperations in hardware. The VDSP module 184 may be controlled by theSPARC processor 182.

The memory module 186 may be implemented as a dynamic random accessmemory (DRAM). The DRAM 186 may be operational to store or buffer largeamounts of information consumed and generated by the decoding operationsand the encoding operations of the video transcoder 180. The DRAM 186may be implemented as a double data rate (DDR) memory. Other memorytechnologies may be implemented to meet the criteria of a particularapplication.

Referring to FIG. 6, a detailed block diagram of an exampleimplementation for the VDSP module 184 is shown. The VDSP module 184generally comprises a module (or circuit) 200, a module (or circuit)202, a module (or circuit) 204, a module (or circuit) 205, a module (orcircuit) 206, a module (or circuit) 208, a module (or circuit) 210, amodule (or circuit) 211, a module (or circuit) 212, a module (orcircuit) 214, a module (or circuit) 216, a module (or circuit) 218, amodule (or circuit) 220, a module (or circuit) 222, a module (orcircuit) 224, a module (or circuit) 226, a module (or circuit) 227, amodule (or circuit) 228, a module (or circuit) 229, a module (orcircuit) 230 and a module (or circuit) 232.

The module 200 may be referred to as a central processor unit interface(CPUI) module. The CPUI module 200 may be operational to store commandsfrom the SPARC processor 182 and queue results. The CPUI module 200 maycommunicate commands from the SPARC processor 182 to the other modules202-232.

The module 202 may be referred to as a direct memory access (DMA)module. The DMA module 202 may be operational to load and store sub-pelinterpolation information to and from the DRAM 186. The DMA module 202may be a DRAM client.

The module 204 may be referred to as a DMA macroblock (DMAMB) module.The DMAMB module 204 may be operational to support sub-pel interpolationfor H.264 operations.

The module 205 may be referred to as a reconstruction macroblock(RECONMB) module. The RECONMB module 205 may be operational to performmacroblock reconstruction for MPEG-2, MPEG-4 and VC-1 streams.

The module 206 may be referred to as another reconstruction macroblock(RECONMB264) module. The RECONMB264 module 206 may be operational toperform forward transforms, inverse transforms, forward quantizationsand inverse quantizations for H.264 streams. Furthermore, the RECONMB264module 206 may be operational to perform forward intra compensation andinverse intra compensation for H.264 streams.

The module 208 may be referred to as a deblocking (DEBLOCK) module. TheDEBLOCK module 208 may be operational to deblock reconstructed pictures.Operation of the DEBLOCK module 208 may be slightly different betweenthe H.264 standard and the VC-1 standard.

The module 210 may be referred to as a memory first in first out (MFIFO)module. The MFIFO module may be operational as a general purpose memoryFIFO.

The module 211 may be referred to as a quantization coefficient memory(QCMEM) module. The QCMEM module 211 may be operational to storequantization coefficients used by the RECONMB module 205. The QCMEMmodule 211 may be implemented as a 3-port memory (e.g., r, w, r/w). TheQCMEM module 211 may be accessible to the SPARC processor 182.

The module 212 may be referred to as a data memory (DMEM) module. TheDMEM module may be operational as a large general purpose data buffer.In one embodiment, the DMEM module 212 may perform the buffering of thememory module 126 (FIG. 2).

The module 214 may be referred to as an intra-frame estimation (IE264)module. The IE264 module 214 may be operational to perform intra-frameestimations for a current macroblock in the H.264 format. The IE264module 214 may be unused in MPEG-2 operations.

The module 216 may be referred to as another quantization coefficientmemory (QCMEM2) module. The QCMEM2 module 216 may store the quantizationcoefficients for the RECONMB264 module 206. The quantizationcoefficients may be stored at a multiple bit (e.g., 12-bit) resolution.The QCMEM2 module 216 may be implemented as a 3-port memory (e.g., r, w,r/w). The QCMEM2 module 216 may be accessible to the SPARC processor182.

The module 218 may be referred to as a macroblock information memory(MBIMEM) module. The MBIMEM module 218 may be operational to storemacroblock coding information.

The module 220 may be referred to as a reconstruct motion vector(RECONMV) module. The RECONMV module 220 may be operational toreconstruct compressed motion vectors.

The module 222 may be referred to as a filter module. The filter modulemay be operational to provide scaling and loop filtering.

The module 224 may be referred to as a coding module. The coding modulemay be operational to perform entropy coding for a bitstream.

The module 226 may be referred to as a variable length decoding (VLD264)module. The VLD264 module 226 may be operational to perform variablelength decoding of the signal IN for H.264 streams.

The module 227 may be referred to as another variable length decoding(VLD) module. The VLD module 227 may be operational to perform variablelength decoding of the signal IN for MPEG-2, MPEG-4 and VC-1 streams.

The module 228 may be referred to as a variable length encoder (VLE264)module. The VLE264 module may be operational to perform a variablelength encoding to generate the signal OUT as an H.264 stream.

The module 229 may be referred to as another variable length encoder(VLE) module. The VLE module may be operational to perform a variablelength encoding to generate the signal OUT as an MPEG-2, MPEG-4 or VC-1stream.

The module 230 may be referred to as a video FIFO (e.g., VFIFO). TheVFIFO module 230 may be operational as a bitstream buffer to bufferhundreds (e.g., 400) of bytes of a bitstream. The VFIFO module 230 maybe a DRAM client.

The module 232 may be referred to as a motion vector memory module(e.g., MVMEM). The MVMEM module 232 may be operational to store motionvectors. In particular, the MVMEM module 232 may hold up to 32 motionvectors per macroblock (e.g., from the H.264 standard). The MVMEM module232 may also be configured to store complex spatial predictions rulesfor the H.264 standard.

The VDSP module 184 may have several configurations, each implementing asubset of the above modules 200-232. For example, a VDSP module 184transcoding from MPEG-2 to VC-1 may eliminate the H.264 specificmodules, such as the VLD264 module 226, the VLE264 module 228, theRECONMB264 module 206 and the IE264 module 214. In some embodiments, theVDSP module 184 may be implemented with all of the modules 200-232. Insuch embodiments, one or more of the modules may not be utilized in aparticular application.

The VDSP module 184 may be implemented in (on) a single chip (or die). Acombination of the SPARC module 182, the VDSP module 184 and the memorymodule 186 may be configured to perform both the decoder moduleoperations and the encoder module operations substantiallysimultaneously. Sharing of the DMEM module 212 for (i) results from thedecoding and (ii) a source of pixel information for the coding generallyallows several coding operations within the VDSP module 184 to beperformed simultaneously with the decoding operations, or a slight delay(e.g., less than a decode time for one picture) after the decodingoperations.

The present invention may take advantage of separate hardware modules ina chip (e.g., the VDSP chip) to support different standards. The supportmay be achieved by allowing the different modules to operate inparallel. Hardware modules that support different standards may run inparallel to reduce a number of cycles and a memory bandwidth for a muchmore efficient transcode compared to existing solutions.

Referring to FIG. 7, a graph of an example time line for different videotranscoding operations is shown. The example may illustrate atranscoding between MPEG-2 and H.264. Similar parallel operations may beperformed between an MPEG-2 and VC-1. As illustrated, the multiplehardware modules in the VDSP module 184 may operate in parallel. Forexample, a macroblock reconstruction (e.g., transform/quantization forencoding and inverse transform/inverse quantization for decoding) for anMPEG-2 decode generally happens at the same time as an H.264 encodereconstruction. In another example, a bitstream decoding (e.g., variablelength decode, VLD) for MPEG-2 decode may happen at the same time as anH.264 bitstream encode for H.264. In still another example, motionvector reconstruction for MPEG-2 decode generally happens at the sametime as motion vector reconstruction for an H.264 encode. Other modules(e.g., motion compensation) may also run in parallel, or in series. Fora serial example, if motion compensation may run twice as fast asreconstruction, then MPEG-2 and H.264 motion compensation may happensequentially relative to each other and in parallel relative to thereconstruction.

A common scratch memory (e.g., DMEM module 212) may be shared betweenthe hardware modules to save both memory space and memory bandwidth. Forexample, the reconstructed pixels from a decode operation may be useddirectly as input pixels for an encode operation. In particular, thereconstructed pixels from the decode operation may become the originalinput to the encode operation without having to reload the pixels to thescratch memory.

A means to synchronize the completion of all parallel hardware units maybe implemented. A synchronization instruction may ensure that executionof all parallel units has completed to provide a synchronization pointfor a control apparatus (e.g., software running on a RISC processorcontrolling the parallel hardware units).

A feature of the present invention is a system where, given that H.264and MPEG-2 hardware to support macroblock reconstruction (e.g.,transform/quantization, inverse transform/inverse quantization) exists,the multiple reconstruction modules for the different video standardsmay operate in parallel and a much more efficient transcode may beimplemented. For example, for an MPEG-2 to H.264 transcode, while theMPEG-2 IDCT function and IQUANT function are executed, the H.264 forwardtransform function and forward quantization function may be executedsimultaneously.

Another feature of the present invention is a system where, given thatH.264 and MPEG-2 hardware to support bitstream encoding and decodingexists, the multiple bitstream encode/decode hardware may operate inparallel and a much more efficient transcode may be implemented. Forexample, for an MPEG-2 to H.264 transcode, while the MPEG-2 bitstreamdecoding (e.g., variable length decode) is being executed, the H.264bitstream encoding (variable length encode) may be executedsimultaneously. Similarly, for the case of content-based adaptivearithmetic code (CABAC) encoding, a content-based adaptive variablelength code (CAVLC) to CABAC transcode may also occur in parallel. Inone embodiment, the video transcoder may have a combination of someunits running in parallel with other units running serially. The presentinvention may be used to transcode audio bitstreams in a similar manneras transcoding the video streams.

As used herein, the term “simultaneously” is meant to describe eventsthat share some common time period but the term is not meant to belimited to events that begin at the same point in time, end at the samepoint in time, or have the same duration.

While the invention has been particularly shown and described withreference to the preferred embodiments thereof, it will be understood bythose skilled in the art that various changes in form and details may bemade without departing from the spirit and scope of the invention.

1. A method for transcoding from an H.264 format to an MPEG-2 format,comprising the steps of: (A) decoding an input video stream in saidH.264 format to generate a picture; (B) determining that said picturehad an H.264 picture adaptive field/frame coding in said input videostream; and (C) coding said picture into an output video stream in saidMPEG-2 format using an MPEG-2 frame mode coding.
 2. The method accordingto claim 1, further comprising the step of: determining an H.264 scanorder of said picture, wherein said coding of said picture into saidoutput video stream is seeded using said H.264 scan order.
 3. The methodaccording to claim 1, further comprising the step of: mapping an H.26416×16 macroblock partition in said picture to at least one of (i) anMPEG-2 16×16 partition and (ii) an MPEG-2 16×8 partition.
 4. The methodaccording to claim 1, further comprising the step of: mapping an H.26416×8 macroblock partition in said picture to an MPEG-2 16×8 partition.5. The method according to claim 1, further comprising the step of:combining a plurality of H.264 motion vectors from an H.264 macroblockpartition in said picture to generate a seed motion vector of an MPEG-2partition.
 6. The method according to claim 5, further comprising thestep of: using said seed motion vector as a motion estimation center ina searchs of an MPEG-2 motion vector.
 7. The method according to claim1, further comprising the step of: adjusting an MPEG-2 group of picturesto utilize a least number of lowest priority frames among a plurality ofMPEG-2 reference frames.
 8. The method according to claim 1, whereinsaid input video stream has an H.264 hierarchical group of pictures, themethod further comprising the step of: prioritizing a plurality offrames in said H.264 hierarchical group of pictures from a highestpriority to a lowest priority to use as a plurality of MPEG-2 referenceframes.
 9. The method according to claim 8, wherein one or more of saidframes highest in said H.264 hierarchical group of pictures receive saidhighest priority.
 10. An apparatus comprising: a circuit configured to(i) decode an input video stream in an H.264 format to generate apicture, (ii) determine that said picture had an H.264 picture adaptivefield/frame coding in said input video stream and (iii) code saidpicture into an output video stream in an MPEG-2 format using an MPEG-2frame mode coding.
 11. The apparatus according to claim 10, wherein (i)said circuit is further configured to determine an H.264 scan order ofsaid picture and (ii) said code of said picture into said output videostream is seeded using said H.264 scan order.
 12. The apparatusaccording to claim 10, wherein said circuit is further configured to mapan H.264 16×16 macroblock partition in said picture to at least one of(i) an MPEG-2 16×16 partition and (ii) an MPEG-2 16×8 partition.
 13. Theapparatus according to claim 10, wherein said circuit is furtherconfigured to map an H.264 16×8 macroblock partition in said picture toan MPEG-2 16×8 partition.
 14. The apparatus according to claim 10,wherein said circuit is further configured to combine a plurality ofH.264 motion vectors from an H.264 macroblock partition in said pictureto generate a seed motion vector of an MPEG-2 partition.
 15. Theapparatus according to claim 14, wherein said circuit is furtherconfigured to use said seed motion vector as a motion compensationcenter of an MPEG-2 motion vector.
 16. The apparatus according to claim10, wherein said circuit is further configured to adjust an MPEG-2 groupof pictures to utilize a least number of lowest priority frames among aplurality of MPEG-2 reference frames.
 17. The apparatus according toclaim 10, wherein (i) said input video stream has an H.264 hierarchicalgroup of pictures and (ii) the circuit is further configured toprioritize a plurality of frames in said H.264 hierarchical group ofpictures from a highest priority to a lowest priority to use as aplurality of MPEG-2 reference frames.
 18. The apparatus according toclaim 17, wherein one or more intra-frames used as reference framesreceive said highest priority.